<template>
	<view class="container">
		<view class="item" v-for="(item, index) in itemList" :key='index'>
			{{item.name}}
		</view>
		<view style="padding-top: 300rpx;" v-if='showEmpty'>
			<u-empty text="暂无数据" mode="list"></u-empty>
		</view>
	</view>
</template>

<script>
	import { common } from '@/api/common.js'
	export default{
		components: {},
		data() {
			return {
				page: 1,
				size: 20,
				itemList: [],
				showEmpty: false,
				isLastPage: false
			}
		},
		onLoad() {
			this.getItemList()
		},
		onPullDownRefresh() {
			this.page = 1
			this.getItemList()
		},
		onReachBottom() {
			if(this.isLastPage) {
				return
			}
			this.getItemList()
		},
		methods:{
			getItemList() {
				common.operateActionGet('/merchant/shop/', {
					page: this.page,
					size: this.size,
				}).then(res => {
					uni.stopPullDownRefresh();
					if (res.data.code == 10000) {
						if(this.page == 1){
							this.itemList = []
						}
						var list = res.data.data.list
						// this.itemList = [...this.itemList, ...list]
						this.showEmpty = this.itemList.length<1
						if (res.data.data.next) {
							this.page += 1
						} else {
							this.isLastPage = true
						}
					}
				})
			},
		}
	}
</script>

<style scoped lang="scss">
	
</style>
